package badgegenerator.model;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

public class User {
    private Integer id;
    private String nickname = null;
    private String password = null;
    private SystemRole role;
//    private List<Employee> employeeList = new ArrayList<Employee>();
    private List<BadgeProject> projectList = new ArrayList<BadgeProject>();

    public User() {
    }
    
    public List<BadgeProject> getProjectList() {
        return projectList;
    }

    public void setProjectList(List<BadgeProject> projectList) {
        this.projectList = projectList;
    }

//    public List<Employee> getEmployeeList() {
//        return employeeList;
//    }
//
//    public void setEmployeeList(List<Employee> employeeList) {
//        this.employeeList = employeeList;
//    }

    public User(String nickname, String password, SystemRole role) {
            super();
            this.nickname = nickname;
            this.password = password;
            this.role = role;
    }
    
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public SystemRole getRole() {
        return role;
    }

    public void setRole(SystemRole role) {
        this.role = role;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final User other = (User) obj;
        if (!Objects.equals(this.id, other.id)) {
            return false;
        }
        if (!Objects.equals(this.nickname, other.nickname)) {
            return false;
        }
        if (!Objects.equals(this.password, other.password)) {
            return false;
        }
        if (this.role != other.role) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        
        builder.append("ID : ");
        builder.append(id);
        builder.append('\n');
        builder.append("Nickname : ");
        builder.append(nickname);
        builder.append('\n');
        builder.append("Password : ");
        builder.append(password);
        builder.append('\n');
        builder.append("Role : ");
        builder.append(role);
        builder.append('\n');
        
        builder.append("=========PROJECTS=========");
        for(BadgeProject proj : projectList){
            builder.append(proj.toString());
        }
        builder.append("=========END OF PROJECTS=========");
        builder.append('\n');
        
        return builder.toString();
    }
}
